import { getProxyPath } from '@/config/proxyPath'
import { createRequest } from '@/utils/mc-request'
import { addparam } from './common/addparam'
const baseURL = getProxyPath('loginAuth')
const request = createRequest({ baseURL })

import mockMenu from '@/assets/mockData/menu.json'
import mockMenuAdmin from '@/assets/mockData/menuAdmin.json'
import { guid } from '@/utils/jcore/easyHash'
import { session } from '@/utils/jcore/storage'

/**用户登录 */
export async function userLogin(data) {
  // return request.postForm('/sysLoginApi/login', data)
  return {
    token: guid(),
    sysUserVo: data
  }
}
/**获取用户菜单 */
export async function getAuthMenuList() {
  const userInfo = session.get('userInfo')
  // return request.postForm('/sysLoginApi/getAuthMenuList', data)
  return userInfo.username == 'admin' ? mockMenuAdmin : mockMenu
}
/**用户登出 */
export function userLogout(data) {
  data = addparam(data)
  return request.postForm('/sysLoginApi/loginout', data)
}
